package CARD;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class cardList {
    private static final String[] SUITS = {"♦", "♥", "♣", "♠"};

    public static List<Card> buycard() {
        List<Card> list = new ArrayList<>();
        for (int i = 0; i < SUITS.length; i++) {

            for (int j = 1; j <= 13; j++) {
                Card card = new Card(SUITS[i], j);
                list.add(card);
            }
        }
        return list;
    }

    public static void shuffle(List<Card> list) {
        Random r = new Random();

        for (int i = list.size() - 1; i > 0; i--) {
            int index = r.nextInt(i);
            swap(list, index, i);
        }
    }

    public static void swap(List<Card> list, int i, int j) {
        Card tmp = list.get(i);
        list.set(i, list.get(j));
        list.set(j, tmp);

    }

    public static List<List<Card>> fapai(List<Card> list) {
        List<List<Card>> player = new ArrayList<>();
        List<Card> player1 = new ArrayList<>();
        List<Card> player2 = new ArrayList<>();
        List<Card> player3 = new ArrayList<>();
        player.add(player1);
        player.add(player2);
        player.add(player3);


        for (int i = 0; i < 5; i++) {

            for (int j = 0; j < 3; j++) {
                Card removeCard = list.remove(0);
                player.get(j).add(removeCard);
            }
        }
        return player;
    }
}
